package com.boot.security.server.common;

/**
 * Created by faze on 2019／01／31.
 */
public enum ErrorCode {

    OK(200, "success"),
    FAIL(-1, "操作失败"),
    SHOW_ERROR(1, "显示错误"),
    DB_ERROR(412, "数据库错误"),
    BUSINESS_ERROR(400, "业务错误"),
    MESSAGE_TOO_OFTEN(401, "消息太频繁请稍后再试"),
    REPEAT_ERROR(406, "信息重复"),
    NOT_FOUND_ERROR(404, "信息未找到"),
    SERVER_ERROR(500, "服务器内部错误"),
    UNAVAILABLE_ERROR(406,"信息不可用"),
    PARAM_IS_NULL(100001,"参数不能为空"),
    SMSCODE_IS_NULL(100002,"短信验证码不能为空"),
    SMSCODE_IS_ERROR(100003,"短信验证码错误"),
    MOBILE_FORMAT_ERROR(-1,"手机号码不正确"),
    UN_LOGIN(-10,"未登陆"),
	ID_CARD_NUMBER_REPEATED(-2, "身份证号重复"),
	IDENTITY_TEST_FAIL(-3, "身份验真失败"),
	//前端统一弹出框处理
	FRONT_END_STYLES(99999, "前端统一弹出框处理"),

	FILE_FORMAT_ERROR(40001, "文件格式不正确"),
	TYPE_ERROR(40002, "数据格式不正确"),
	FILE_DATA_REPEAT(40004, "数据重复"),
	FILE_UPLOAD_ERROR(40003, "文件格上传失败"),
    FILE_PARSE_ERROR(40005,"文件解析失败"),

    USER_NOT_FOUND(50001,"未找到用户"),
    USER_DISABLE(50002,"账号已停用"),
    USER_PASSWORD_ERROR(50003,"用户名或密码错误"),
    SIGN_ERROR(25,"签名错误");

    private int code;
    private String message;

    private ErrorCode(int code, String message) {
        this.code = code;
        this.message = message;
    }

    public int getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

    public static ErrorCode getByCode(final int code) {
        final ErrorCode[] values = ErrorCode.values();
        for (final ErrorCode value : values) {
            if (value.getCode() == code)
                return value;
        }
        return null;
    }
}
